package com.ruoyi.aqi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aqi.domain.AqiDay;
import com.ruoyi.aqi.service.IAqiDayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * AQI天Controller
 * 
 * @author houtaroy
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/aqi/aqiDay")
public class AqiDayController extends BaseController
{
    @Autowired
    private IAqiDayService aqiDayService;

    /**
     * 查询AQI天列表
     */
    @PreAuthorize("@ss.hasPermi('aqi:aqiDay:list')")
    @GetMapping("/list")
    public TableDataInfo list(AqiDay aqiDay)
    {
        startPage();
        List<AqiDay> list = aqiDayService.selectAqiDayList(aqiDay);
        return getDataTable(list);
    }

    /**
     * 导出AQI天列表
     */
    @PreAuthorize("@ss.hasPermi('aqi:aqiDay:export')")
    @Log(title = "AQI天", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AqiDay aqiDay)
    {
        List<AqiDay> list = aqiDayService.selectAqiDayList(aqiDay);
        ExcelUtil<AqiDay> util = new ExcelUtil<AqiDay>(AqiDay.class);
        util.exportExcel(response, list, "AQI天数据");
    }

    /**
     * 获取AQI天详细信息
     */
    @PreAuthorize("@ss.hasPermi('aqi:aqiDay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(aqiDayService.selectAqiDayById(id));
    }

    /**
     * 新增AQI天
     */
    @PreAuthorize("@ss.hasPermi('aqi:aqiDay:add')")
    @Log(title = "AQI天", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AqiDay aqiDay)
    {
        return toAjax(aqiDayService.insertAqiDay(aqiDay));
    }

    /**
     * 修改AQI天
     */
    @PreAuthorize("@ss.hasPermi('aqi:aqiDay:edit')")
    @Log(title = "AQI天", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AqiDay aqiDay)
    {
        return toAjax(aqiDayService.updateAqiDay(aqiDay));
    }

    /**
     * 删除AQI天
     */
    @PreAuthorize("@ss.hasPermi('aqi:aqiDay:remove')")
    @Log(title = "AQI天", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(aqiDayService.deleteAqiDayByIds(ids));
    }
}
